package cloud.seri.auth.domain

import org.springframework.data.annotation.Id
import org.springframework.data.mongodb.core.mapping.DBRef
import org.springframework.data.mongodb.core.mapping.Document
import org.springframework.data.mongodb.core.mapping.Field
import java.io.Serializable
import javax.persistence.Entity
import javax.validation.constraints.NotNull
import javax.validation.constraints.Size

/**
 * A Dept.
 */
@Document(collection = "seri_dept")
@Entity
class Dept(

    @Id
    var id: String? = null,

    @get: NotNull
    @get: Size(max = 45)
    @Field("dept_name")
    var title: String? = null,

    @get: Size(max = 45)
    @Field("full_name")
    var fullName: String? = null,

    @Field("sort")
    var sort: Int? = null,

    @Field("remark")
    var remark: String? = null,

    @Field("status")
    var status: Int? = null,

//    @DBRef(lazy = true)
//    @Field("children")
//    var children: MutableSet<Dept> = mutableSetOf(),

    @DBRef
    @Field("parent")
//    @JsonIgnoreProperties("children")
    var parent: Dept? = null
) : Serializable
